/******************************************************************************
*
* Copyright (C) 2018 - 2028 FMSH, Inc.  All rights reserved.
*
******************************************************************************/
/******************************************************************************
*
* @file  fmsh_dmac_config.h
*
* This file contains header fmsh_common.h.
*
* @note		None.
*
* MODIFICATION HISTORY:
*
*<pre>
* Ver   Who  Date     Changes
* ----- ---- -------- ---------------------------------------------
* 0.01   lq  08/28/2022  First Release.
*</pre>
******************************************************************************/
#ifndef _FMSH_DMAC_CONFIG_H_
#define _FMSH_DMAC_CONFIG_H_

/***************************** Include Files *********************************/
#include "fmsh_common.h"
#include "fmsh_ps_parameters.h"
#include "fmsh_dmac_lib.h"
#include "fmsh_dmac_hw.h"
#include "fmsh_dmac_private.h"

/**************************** Type Definitions *******************************/
 
/***************** Macros (Inline Functions) Definitions *********************/ 
// Source memory location
#define SRC_MEMORY_BASE          (FPS_AHB_SRAM_BASEADDR)
// Destination memory location
#define DST_MEMORY_BASE          (FPS_AHB_SRAM_BASEADDR + 0x10000)
// LLI start address
#define LLI_MEMORY_BASE          (FPS_AHB_SRAM_BASEADDR + 0x5000)
#define LLI_MEMORY_OFFSET        (0x500)

#define DMAC_TEST_BLOCK_SIZE     2048

/************************** Variable Definitions *****************************/ 
extern enum FMSH_compType g_DMA_compType; 		// dma component type
extern u32 g_DMA_compVersion;	// dma component version
extern enum FDmaPs_channelNumber g_DMA_chNum; 	// Select a DMA channel
extern enum FDmaPs_transferType g_DMA_transType; // Select a transfer type
// Set src/dst address
extern u32 g_DMA_srcAddress;
extern u32 g_DMA_dstAddress;
extern u32 g_DMA_blockSize; // Select the size of a block
extern u32 g_DMA_numBlocks; // Select the number of blocks
// Set the source and destination transfer width
extern enum FDmaPs_transferWidth g_DMA_ctlSrcTrWidth;
extern enum FDmaPs_transferWidth g_DMA_ctlDstTrWidth;
// Set the Address increment type for the source and destination
extern enum FDmaPs_addressIncrement g_DMA_ctlSinc;
extern enum FDmaPs_addressIncrement g_DMA_ctlDinc;
// Set the source and destination burst transaction length
extern enum FDmaPs_burstTransLength g_DMA_ctlSrcMsize;
extern enum FDmaPs_burstTransLength g_DMA_ctlDstMsize;
// set scatter and gather enable
extern enum FMSH_state g_DMA_ctlDstScatterEn;
extern enum FMSH_state g_DMA_ctlSrcGatherEn;
// Set the transfer device type and flow controller
extern enum FDmaPs_transferFlow g_DMA_ctlTtFc;

// Set handshaking select
extern enum FDmaPs_swHwHsSelect g_DMA_cfgHsSelSrc;
extern enum FDmaPs_swHwHsSelect g_DMA_cfgHsSelDst;
// Set handshaking interface polarity
extern enum FDmaPs_polarityLevel g_DMA_cfgSrcHsPol;
extern enum FDmaPs_polarityLevel g_DMA_cfgDstHsPol;
// Set FIFO mode select
extern enum FDmaPs_fifoMode g_DMA_cfgFifoMode;
// Set hardware handshaking interface
extern enum FDmaPs_hsInterface g_DMA_cfgDestPer;
extern enum FDmaPs_hsInterface g_DMA_cfgSrcPer;

// set source gather parameters
extern u32 g_DMA_sgrSgc;
extern u32 g_DMA_sgrSgi;
// set destination scatter parameters
extern u32 g_DMA_dsrDsc;
extern u32 g_DMA_dsrDsi;

typedef struct _dmac_channel_info {
	u8                            ch_en;
	u16                           block_num;
	enum FDmaPs_transferType      transfer_type;
    u32                           sar;
    u32                           dar;
    enum FDmaPs_transferWidth     ctl_dst_tr_width;
    enum FDmaPs_transferWidth     ctl_src_tr_width;
	u16                           ctl_block_ts;
	enum FDmaPs_transferFlow      ctl_tt_fc;
    enum FDmaPs_burstTransLength  ctl_dst_msize;
    enum FDmaPs_burstTransLength  ctl_src_msize;
    enum FDmaPs_addressIncrement  ctl_dinc;
    enum FDmaPs_addressIncrement  ctl_sinc;
	u8                            cfg_ch_prior;
	u8                            cfg_ch_susp;
    enum FDmaPs_fifoMode          cfg_fifo_mode;
    enum FMSH_state               ctl_src_gather_en;
    enum FMSH_state               ctl_dst_scatter_en;
    u32                           sgr_sgi;
    u16                           sgr_sgc;
    u32                           dsr_dsi;
    u16                           dsr_dsc;
	u8                            src_mem_type;
	u8                            dst_mem_type;
	FMSH_listHead                 list_head;
}FDmaPs_ChannelInfo;

#endif /* #ifndef _DMAC_CONFIG_H_ */
